package com.bangcommunity.bbframe.mlog.logger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author tanghc
 * @date 18/1/29
 */
public abstract class MLogFacade {
    static Logger logger = LoggerFactory.getLogger(MLogFacade.class);
    public static boolean isMLogTraceEnable() {
        return AsynQueuedMLogTracer.isTraceEnable();
    }

    public static void trace(String format, Object... args) {
        try {
            AsynQueuedMLogTracer.trace(format, args);
        } catch (Exception e) {
            logger.error("mlog trace error:{}",e.getMessage());
        }
    }

    /**
     *
     * @param mkey
     *            实际日志名称使用的标识
     * @param format
     * @param args
     */
    public static void traceByMkey(String mkey, String format, Object... args) {
        try {
            AsynQueuedMLogTracer.trace(mkey, format, args);
        } catch (Exception e) {
            logger.error("mlog traceByMkey error:{}", e.getMessage());
        }
    }

    /**
     *
     * @param key
     *            业务指定标识。会自动将productCode和appCode和key进行串联 形成mkey
     * @param format
     * @param args
     */
    public static void traceByKey(String key, String format, Object... args) {
        try {
            AsynQueuedMLogTracer.traceByKey(key, format, args);
        } catch (Exception e) {
            logger.error("mlog traceByKey error:{}", e.getMessage());
        }
    }
}